﻿using System;
using System.Windows.Forms;

public static class Extensions
{
    public static void SetValue(this HtmlElement @this, string value)
    {
        @this.SetAttribute("value", value);
    }

    public static string GetValue(this HtmlElement @this)
    {
        return @this.GetAttribute("value");
    }

    public static void SetChecked(this HtmlElement @this, bool value)
    {
        @this.SetAttribute("checked", value.ToString());
    }

    public static bool GetChecked(this HtmlElement @this)
    {
        return Convert.ToBoolean(@this.GetAttribute("checked"));
    }

    public static HtmlElement InsertRow(this HtmlElement @this)
    {
        HtmlElement tr = @this.Document.CreateElement("tr");
        HtmlElement body = @this.Children[0];
        body.AppendChild(tr);
        
        return tr;
    }

    public static HtmlElement InsertCell(this HtmlElement @this)
    {
        HtmlElement td = @this.Document.CreateElement("td");
        @this.AppendChild(td);

        return td;
    }

    public static void DeleteRow(this HtmlElement @this, HtmlElement row)
    {
    }

    public static string GetCssClass(this HtmlElement @this)
    {
        return @this.GetAttribute("className");
    }

    public static void SetCssClass(this HtmlElement @this, string value)
    {
        @this.SetAttribute("className", value);
    }

    public static int RowLength(this HtmlElement @this)
    {
        return @this.Children[0].Children.Count;
    }

    public static HtmlElementCollection GetRows(this HtmlElement @this)
    {
        return @this.Children[0].Children;
    }
}